import { Component } from '@angular/core';

@Component({
  templateUrl: './demo5.component.html',
  styles: [
    `
      .content { color: #000; }
    `
  ],
})
export class Demo5Component {
  beforeExpanded = (collapse) => {
    if(collapse.lvId === 'p1') {
      collapse.lvLoading = true;
      return new Promise<void>(resolve => {
        setTimeout(() => {
          console.log('Do something before expanded.');
          collapse.lvLoading = false;
          resolve();
        }, 2000);
      })
    }

    if(collapse.lvId === 'p2') {
      collapse.lvLoading = true;
      return new Promise(resolve => {
        setTimeout(() => {
          collapse.lvLoading = false;
          resolve(false);
          alert('Content load failed.');
        }, 2000);
      })
    }
  }

  afterExpanded = () => {
     console.log('Expanded!');
  }
}